package com.y.report.controller.basic;


import com.y.report.entity.basic.YReportDs;
import com.y.report.entity.common.Q;
import com.y.report.entity.common.R;
import com.y.report.entity.common.U;
import com.y.report.service.basic.YReportDsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 * 数据源信息表 前端控制器
 * </p>
 *
 * @author y
 * @since 2021-09-23
 */
@RestController
@RequestMapping("/y-report-ds")
@Api(tags = "ds信息信息控制器")
public class YReportDsController {
    @Autowired
    private YReportDsService yReportDsService;

    @PostMapping("/save")
    @ApiOperation("添加")
    public R save(@RequestBody YReportDs save) {
        return R.success(yReportDsService.appendMultiple(Collections.singletonList(save)));
    }

    @PostMapping("/query")
    @ApiOperation("查询列表")
    public R query(@RequestBody Q<YReportDs> query) {
        R<List<YReportDs>> result = R.success(yReportDsService.queryCondition(query.getEqObj(), query.getLikeObj(), query.getPage()));
        if (query.getPage() != null)
            result.setExtData(query.getPage());
        return result;
    }

    @PutMapping("/modify")
    @ApiOperation("修改")
    public R modify(@RequestBody U<YReportDs> modify) {
        return R.success(yReportDsService.modifyCondition(modify.getModifyObj(), modify.getQueryObj()));
    }
}

